package sbc.group1.lab1.alt;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import org.mozartspaces.core.MzsCoreException;

import sbc.group1.lab1.common.CarBody;
import sbc.group1.lab1.common.Engine;
import sbc.group1.lab1.common.Producer;
import sbc.group1.lab1.common.Wheel;

public class BunchProduce {
    
    private CarService cs;
    private final Producer producer;
    
    public static void main(String args[]) throws MalformedURLException, MzsCoreException, URISyntaxException, RemoteException, NotBoundException {
        new BunchProduce().run();
    }
    
    public BunchProduce() throws MalformedURLException, RemoteException, NotBoundException {
        cs= (CarService)
            Naming.lookup("rmi://localhost:1099/CarService");
        this.producer = new Producer() {
            @Override
            public int getId() {
                return 1;
            }
        };
    }
    
    public void run() throws RemoteException {
        
        for (int i=0; i<2000; i++) {
            cs.addCarBody(new CarBody(producer, false));
            cs.addEngine(new Engine(producer, Engine.Type.T100KW, false));
            cs.addWheel(new Wheel(producer, false));
            cs.addWheel(new Wheel(producer, false));
            cs.addWheel(new Wheel(producer, false));
            cs.addWheel(new Wheel(producer, false));
        }
    }
}
